﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _42 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "UserNumber",
                table: "AttendanceRecord",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                comment: "工号",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldComment: "工号")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<Guid>(
                name: "UserId",
                table: "AttendanceRecord",
                type: "char(36)",
                nullable: true,
                comment: "用户Id",
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldComment: "用户Id")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AlterColumn<int>(
                name: "AttendanceType",
                table: "AttendanceRecord",
                type: "int",
                nullable: true,
                comment: "考勤类型\r\n            1.员工考勤\r\n            2.幼儿考勤",
                oldClrType: typeof(int),
                oldType: "int",
                oldComment: "考勤类型\r\n            1.员工考勤\r\n            2.幼儿考勤");

            migrationBuilder.AddColumn<DateTime>(
                name: "CreateTime",
                table: "AttendanceRecord",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                comment: "创建时间");

            migrationBuilder.CreateTable(
                name: "AttendanceRecordTemp",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    UserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "用户Id", collation: "ascii_general_ci"),
                    AttendanceTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "打卡时间"),
                    AttendanceType = table.Column<int>(type: "int", nullable: true, comment: "考勤类型\r\n            1.员工考勤\r\n            2.幼儿考勤"),
                    AttendanceGroup = table.Column<Guid>(type: "char(36)", nullable: true, comment: "考勤组", collation: "ascii_general_ci"),
                    UserNumber = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "工号")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AttendanceRecordTemp", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_AttendanceRecordTemp_CreateTime",
                table: "AttendanceRecordTemp",
                column: "CreateTime");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AttendanceRecordTemp");

            migrationBuilder.DropColumn(
                name: "CreateTime",
                table: "AttendanceRecord");

            migrationBuilder.AlterColumn<string>(
                name: "UserNumber",
                table: "AttendanceRecord",
                type: "longtext",
                nullable: false,
                comment: "工号",
                oldClrType: typeof(string),
                oldType: "varchar(100)",
                oldMaxLength: 100,
                oldComment: "工号")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<Guid>(
                name: "UserId",
                table: "AttendanceRecord",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                comment: "用户Id",
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldNullable: true,
                oldComment: "用户Id")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AlterColumn<int>(
                name: "AttendanceType",
                table: "AttendanceRecord",
                type: "int",
                nullable: false,
                defaultValue: 0,
                comment: "考勤类型\r\n            1.员工考勤\r\n            2.幼儿考勤",
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true,
                oldComment: "考勤类型\r\n            1.员工考勤\r\n            2.幼儿考勤");
        }
    }
}
